<template>
  <div class="header">
    <div class="logo">
      <a href="/index.aspx">
        <img alt="小麦子日淘日本转运海淘" src="../assets/images/header-logo-gray.png">
      </a>
    </div>

    <div class="logining" v-if="name.length>0">
        <router-link to="/home">{{name}},您好</router-link>
        <span>|</span>
        <a href="javascript:void(0);" @click="logout">退出</a>
    </div>
    <div class="unlogin" v-else>
        <router-link to="/login">登录</router-link>
        <a class="linkheaderReg" href="/regcontent/">注册</a>
    </div>
    <div class="nav">
      <a href="/zhinancontent/hxd_361.html">利用指南</a>
      <a href="/Free.aspx">日本转运</a>
      <a href="/GongLv-hx/383.html">日淘推荐</a>
      <a href="/GongLv.aspx">日淘社区</a>
      <a href="/about.aspx">关于我们</a>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'Header',
  computed: {
    ...mapGetters([
      'userInfo'
    ]),
    name () {
      return this.userInfo.userName
    }
  },
  methods: {
    ...mapActions([
      'setUserInfo'
    ]),
    logout: function () {
      this.setUserInfo({
        msg_id: 0,
        user_name: ''
      })
      this.$config.token.set('')
      this.$router.push({
        path: '/'
      })
    }
  }
}

</script>
